package com.hrsoft.modules.bid.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hrsoft.modules.bid.entity.BiddingEntity;
import com.hrsoft.modules.bid.service.BiddingService;
import com.hrsoft.common.utils.PageUtils;
import com.hrsoft.common.utils.R;



/**
 * 投标申请
 *
 * @author garfield.yue
 * @email yuedefeng101@163.com
 * @date 2020-05-07 10:42:28
 */
@RestController
@RequestMapping("bid/bidding")
public class BiddingController {
    @Autowired
    private BiddingService biddingService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bid:bidding:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = biddingService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("bid:bidding:info")
    public R info(@PathVariable("id") Integer id){
		BiddingEntity bidding = biddingService.getById(id);

        return R.ok().put("bidding", bidding);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bid:bidding:save")
    public R save(@RequestBody BiddingEntity bidding){
		biddingService.save(bidding);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bid:bidding:update")
    public R update(@RequestBody BiddingEntity bidding){
		biddingService.updateById(bidding);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bid:bidding:delete")
    public R delete(@RequestBody Integer[] ids){
		biddingService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
